//package com.fowo.api.service.impl;
//
//import cn.hutool.core.lang.Assert;
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.fowo.api.entity.StockOut;
//import com.fowo.api.mapper.StockOutMapper;
//import com.fowo.api.model.receivable.ReceivableVo;
//import com.fowo.api.model.receivable.product.ReceivableProductItemVo;
//import com.fowo.api.model.stock.out.StockOutCreateReceivableAction;
//import com.fowo.api.model.stock.out.StockOutVo;
//import com.fowo.api.model.stock.out.product.StockOutProductItemVo;
//import com.fowo.api.service.ReceivableService;
//import com.fowo.api.service.StockOutService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 出库单的生成应收单行为接口
// */
//@Service
//@Slf4j
//@DS("ds24")
//public class StockOutCreateReceivableActionImpl
//        extends ServiceImpl<StockOutMapper, StockOut>
//       {
//
//    @Resource
//    private StockOutService stockOutService;
//    @Resource
//    private ReceivableService receivableService;
//
//    public void run(Long id) throws Exception {
//        StockOutVo stockOut = stockOutService.getVoById(id);
//
//        Assert.isTrue(stockOut.getStatus() == "CS02","只能生成审核通过的单据！");
//        Assert.isTrue(stockOut.getType() == "CK001","单据类型错误！");
//
//        ReceivableVo receivable = new ReceivableVo();
//        receivable.setType("YS01");
//        receivable.setCustomer(stockOut.getCustomer());
//        receivable.setCurrency("CNY");
//        receivable.setCloseOrg(stockOut.getDept());
//        receivable.setReceiptOrg(stockOut.getDept());
//        receivable.setAccountType("");
//        receivable.setBusinessDate(stockOut.getOutTime());
//        receivable.setDueDate(stockOut.getOutTime());
//        receivable.setReceiptTerms("SKTJ01_SYS");
//        receivable.setOrderer(stockOut.getCustomer());
//        receivable.setConsignee(stockOut.getCustomer());
//        receivable.setPayer(stockOut.getCustomer());
//
//        ReceivableProductItemVo productItemVo ;
//        List<ReceivableProductItemVo> products = new ArrayList<>();
//        for(StockOutProductItemVo item : stockOut.getStockOutProducts()){
//            productItemVo = new ReceivableProductItemVo();
//            productItemVo.setProductCode(item.getProductId());
//            productItemVo.setProductSku(item.getSku());
//            productItemVo.setProductName(item.getProductName());
//            productItemVo.setUnit("");
//            productItemVo.setNum(item.getProductGoodNum());
//            productItemVo.setPrice(item.getPrice());
//            productItemVo.setStorageBinNum(item.getStorageBinGoodNum());
//            productItemVo.setAmount(item.getFeeCost());
//            products.add(productItemVo);
//        }
//        receivable.setProducts(products);
//        receivableService.create(receivable);
//    }
//}
